import Vue from 'vue'
import Router from 'vue-router'
import Center from '@/components/center/center'
import Financial from '@/components/financial/financial'
import Manage from '@/components/manage/manage'
import Report from '@/components/report/report'
import OA from '@/components/oa/oa'
import BasicData from '@/components/basicData/basicData'
import Login from '@/components/login'
//会计科目
import AccountSubject from '@/components/basicData/accountSubject'
import AccoutSubjectTab from '@/components/basicData/accountSubject/tab'
import AccoutSubjectSelectType from '@/components/basicData/accountSubject/selectType'
import AccoutSubjectGroup from '@/components/basicData/accountSubject/subjectGroup'
import AccoutSubjectGroupForm from '@/components/basicData/accountSubject/subjectGroupForm'
//币别
import currencyType from '@/components/basicData/currencyType'
import currencyTypeForm from '@/components/basicData/currencyType/form'
//计量单位
import meterUnit from '@/components/basicData/meterUnit'
import unitGroupForm from '@/components/basicData/meterUnit/unitGroupForm'
import unitForm from '@/components/basicData/meterUnit/unitForm'
//结算方式
import settlementWay from '@/components/basicData/settlementWay'
import settlementWayForm from '@/components/basicData/settlementWay/form'
//核算项目
import checkItems from '@/components/basicData/checkItems'
import checkItemsForm from '@/components/basicData/checkItems/checkItemsForm'
import selectTypes from '@/components/basicData/checkItems/selectTypes'
//辅助资料
import auxiliary from '@/components/basicData/auxiliary'
import subClassForm from '@/components/basicData/auxiliary/subClassForm'
import carNumberForm from '@/components/basicData/auxiliary/carNumberForm'
import contractNumberForm from '@/components/basicData/auxiliary/contractNumberForm'
import goodsInfoForm from '@/components/basicData/auxiliary/goodsInfoForm'
import ordinaryForm from '@/components/basicData/auxiliary/ordinaryForm'
import bankForm from '@/components/basicData/auxiliary/bankForm'
//城市字典
import cityDictionary from '@/components/basicData/cityDictionary'
//账套
import Account from '@/components/basicData/account'
import updateYear from '@/components/basicData/account/updateYear'
//上机日志
import NetLog from '@/components/basicData/netLog'
//部门资料
import Department from '@/components/basicData/department'
import DepartmentForm from '@/components/basicData/department/departmentForm'
import selectDepartment from '@/components/basicData/department/selectDepartment'
//职员
import Employee from '@/components/basicData/employee'
import EmployeeForm from '@/components/basicData/employee/form'
import EmployeeAddDepartment from '@/components/basicData/employee/addDepartment'
import EmployeeView from '@/components/basicData/employee/view'
//客户资料
import Customer from '@/components/basicData/customer'
import CustomerForm from '@/components/basicData/customer/customerForm'
import CustomerSelectDeparment from '@/components/basicData/customer/selectDepartment'
import ViewCustomer from '@/components/basicData/customer/view'
//供应商资料
import Supplier from '@/components/basicData/supplier'
import SupplierForm from '@/components/basicData/supplier/supplierForm'
import SupplierSelectDeparment from '@/components/basicData/supplier/selectDepartment'
import ViewSupplier from '@/components/basicData/supplier/view'
//用户组管理
import UserGroup from '@/components/basicData/userGroup'
import UserGroupForm from '@/components/basicData/userGroup/form'
//审批流程
import verifyProcess from '@/components/basicData/verifyProcess'
import oneAdd from '@/components/basicData/verifyProcess/oneAdd'
import twoAdd from '@/components/basicData/verifyProcess/twoAdd'
import threeAdd from '@/components/basicData/verifyProcess/threeAdd'
import fourAdd from '@/components/basicData/verifyProcess/fourAdd'
import fiveAdd from '@/components/basicData/verifyProcess/fiveAdd'
//用户管理
import UserManagement from '@/components/basicData/userManagement/UserManagement'
import Authorization from '@/components/basicData/userManagement/Authorization'
import AuthorizationAddCustomer from '@/components/basicData/userManagement/addCustomerAuthorized'
import UpdateUserManagement from '@/components/basicData/userManagement/updateUserManagement'
import Documents from '@/components/basicData/userManagement/Documents'
//初始化
import Initialize from '@/components/basicData/initialize/Initialize'
import SubsidiaryLedger1 from '@/components/basicData/initialize/subsidiaryLedger1'
import SubsidiaryLedger2 from '@/components/basicData/initialize/subsidiaryLedger2'
import SubsidiaryLedger3 from '@/components/basicData/initialize/subsidiaryLedger3'
import SubsidiaryLedger4 from '@/components/basicData/initialize/subsidiaryLedger4'
import Balance from '@/components/basicData/initialize/balance'
import Objects from '@/components/basicData/initialize/object'
import ObjectTwo from '@/components/basicData/initialize/objectTwo'
import ObjectThree from '@/components/basicData/initialize/objectThree'
import XsCompact from '@/components/basicData/initialize/xscompactCode'
import CgCompact from '@/components/basicData/initialize/cgcompactCode'
import BankData from '@/components/basicData/initialize/bankData'
//启用系统
import EnableSystem from '@/components/basicData/enableSystem'
//借款类别模板
import BorrowCategory from '@/components/basicData/borrowCategory'
import BorrowCategoryForm from '@/components/basicData/borrowCategory/borrowCategoryForm'
//借款单
import BorrowOrder from '@/components/financial/borrowOrder'
import BorrowOrderForm from '@/components/financial/borrowOrder/form'
import BorrowOrderApprovePage from '@/components/financial/borrowOrder/approvePage'
import viewBorrowOrder from '@/components/financial/borrowOrder/view'
import selectBorrowCategory from '@/components/financial/borrowOrder/borrowCategory'
import selectBorrowOrderBank from '@/components/financial/borrowOrder/bank'
//借款类别审批单
import BorrowApproveOrder from '@/components/financial/borrowApproveOrder'
import BorrowApproveOrderForm from '@/components/financial/borrowApproveOrder/form'
import BorrowApproveOrderApprovePage from '@/components/financial/borrowApproveOrder/approvePage'
import viewBorrowApproveOrder from '@/components/financial/borrowApproveOrder/view'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'basicData',
      component: BasicData,
      redirect: '/basicData'
    },
//================== 基础资料 =======================================
    {
      path: '/basicData',
      name: 'BasicData',
      component: BasicData
    },
    {
      path: '/basicData/currencyType',    //币别
      name: 'currencyType',
      component: currencyType
    },
    {
      path: '/basicData/currencyType/form',    //币别-新增修改
      name: 'currencyTypeForm',
      component: currencyTypeForm
    },
    {
      path: '/basicData/accountSubject',    //会计科目
      name: 'AccountSubject',
      component: AccountSubject
    },
    {
      path: '/basicData/accountSubject/tab',    //会计科目-新增与修改
      name: 'AccoutSubjectTab',
      component: AccoutSubjectTab
    },
    {
      path: '/basicData/accountSubject/tab/selectType',     //会计科目-选择核算类别
      name: 'AccoutSubjectSelectType',
      component: AccoutSubjectSelectType
    },
    {
      path: '/basicData/accountSubject/subjectGroup',     //会计科目-科目组
      name: 'AccoutSubjectGroup',
      component: AccoutSubjectGroup
    },
    {
      path: '/basicData/accountSubject/subjectGroup/subjectGroupForm',     //会计科目-科目组-新增修改目录
      name: 'AccoutSubjectGroupForm',
      component: AccoutSubjectGroupForm
    },
    {
      path: '/basicData/meterUnit',    //计量单位
      name: 'meterUnit',
      component: meterUnit
    },
    {
      path: '/basicData/meterUnit/unitGroupForm',    //计量单位组-新增与修改
      name: 'unitGroupForm',
      component: unitGroupForm
    },
    {
      path: '/basicData/meterUnit/unitForm',    //计量单位-新增与修改
      name: 'unitForm',
      component: unitForm
    },
    {
      path: '/basicData/settlementWay',         //结算方式
      name: 'settlementWay',
      component: settlementWay
    },
    {
      path: '/basicData/settlementWay/form',         //结算方式-新增修改
      name: 'settlementWayForm',
      component: settlementWayForm
    },
    {
      path: '/basicData/checkItems',    //核算项目
      name: 'checkItems',
      component: checkItems
    },
    {
      path: '/basicData/checkItems/form',    //核算项目-新增与修改
      name: 'checkItemsForm',
      component: checkItemsForm
    },
    {
      path: '/basicData/checkItems/selectTypes',    //核算项目-上级类别页面
      name: 'selectTypes',
      component: selectTypes
    },
    {
      path: '/basicData/auxiliary',       //辅助资料
      name: 'auxiliary',
      component: auxiliary
    },
    {
      path: '/basicData/auxiliary/subClassForm',       //辅助资料-小类新增与修改
      name: 'subClassForm',
      component: subClassForm
    },
    {
      path: '/basicData/auxiliary/carNumberForm',       //辅助资料-车牌号码新增修改
      name: 'carNumberForm',
      component: carNumberForm
    },
    {
      path: '/basicData/auxiliary/contractNumberForm',       //辅助资料-合同编号新增修改
      name: 'contractNumberForm',
      component: contractNumberForm
    },
    {
      path: '/basicData/auxiliary/goodsInfoForm',       //辅助资料-货号资料新增修改
      name: 'goodsInfoForm',
      component: goodsInfoForm
    },
    {
      path: '/basicData/auxiliary/ordinaryForm',       //辅助资料-普通资料新增修改
      name: 'ordinaryForm',
      component: ordinaryForm
    },
    {
      path: '/basicData/auxiliary/bankForm',       //辅助资料-银行资料新增修改
      name: 'bankForm',
      component: bankForm
    },
    {
      path: '/basicData/cityDictionary',       //城市字典
      name: 'cityDictionary',
      component: cityDictionary
    },
    {
      path: '/basicData/netLog',       //上机日志
      name: 'NetLog',
      component: NetLog
    },
    {
      path: '/basicData/department',        //部门
      name: 'Department',
      component: Department
    },
    {
      path: '/basicData/department/selectDepartment',        //所有部门页面
      name: 'selectDepartment',
      component: selectDepartment
    },
    {
      path: '/basicData/department/form',        //部门-新增与修改
      name: 'DepartmentForm',
      component: DepartmentForm
    },
    {
      path: '/basicData/employee',          //职员
      name: 'Employee',
      component: Employee
    },
    {
      path: '/basicData/employee/form',       //职员新增修改
      name: 'EmployeeForm',
      component: EmployeeForm
    },
    {
      path: '/basicData/employee/EmployeeAddDepartment',        //职员-部门选择弹窗
      name: 'EmployeeAddDepartment',
      component: EmployeeAddDepartment
    },
    {
      path: '/basicData/employee/view',     //查看职员信息弹窗
      name: 'EmployeeView',
      component: EmployeeView
    },
    {
      path: '/basicData/customer',     //客户资料
      name: 'Customer',
      component: Customer
    },
    {
      path: '/basicData/customer/form',     //客户资料-新增与修改
      name: 'CustomerForm',
      component: CustomerForm
    },
    {
      path: '/basicData/customer/selectDepartment',       //客户资料-分管部门窗口
      name: 'CustomerSelectDeparment',
      component: CustomerSelectDeparment
    },
    {
      path: '/basicData/customer/view',         //查看客户资料
      name: 'ViewCustomer',
      component: ViewCustomer
    },
    {
      path: '/basicData/supplier',      //供应商资料
      name: 'Supplier',
      component: Supplier
    },
    {
      path: '/basicData/supplier/form',     //供应商资料-新增与修改
      name: 'SupplierForm',
      component: SupplierForm
    },
    {
      path: '/basicData/supplier/selectDepartment',       //供应商资料-分管部门窗口
      name: 'SupplierSelectDeparment',
      component: SupplierSelectDeparment
    },
    {
      path: '/basicData/supplier/view',         //查看供应商资料
      name: 'ViewSupplier',
      component: ViewSupplier
    },
    
    {
      path: '/userManagement',            //用户管理
      name: 'UserManagement',
      component: UserManagement
    },
    {
      path: '/userManagement/Authorization',            //用户管理授权
      name: 'Authorization',
      component: Authorization
    },
    {
      path: '/userManagement/addCustomerAuthorized',    //用户管理授权新增客户查看权限
      name: 'AuthorizationAddCustomer',
      component: AuthorizationAddCustomer
    },
    {
      path: '/userManagement/updateUserManagement',    //修改用户管理
      name: 'UpdateUserManagement',
      component: UpdateUserManagement
    },
    {
      path: '/userManagement/Documents',    //用户管理的单据模块
      name: 'Documents',
      component: Documents
    },
    {
      path: '/basicData/userGroup',         //用户组管理
      name: 'UserGroup',
      component: UserGroup
    },
    {
      path: '/basicData/userGroup/form',         //用户组管理-新增修改
      name: 'UserGroupForm',
      component: UserGroupForm
    },
    {
      path: '/initialize',                //初始化
      name: 'Initialize',
      component: Initialize
    },
    {
      path: '/initialize/subsidiaryLedger1',         //银行存款明细账
      name: 'SubsidiaryLedger1',
      component: SubsidiaryLedger1
    },
    {
      path: '/initialize/subsidiaryLedger2',         //应收账款明细账
      name: 'SubsidiaryLedger2',
      component: SubsidiaryLedger2
    },
    {
      path: '/initialize/subsidiaryLedger3',         //应付账款明细账
      name: 'SubsidiaryLedger3',
      component: SubsidiaryLedger3
    },
    {
      path: '/initialize/subsidiaryLedger4',         //普通明细账
      name: 'subsidiaryLedger4',
      component: SubsidiaryLedger4
    },
    {
      path: '/initialize/balance',              //试算平衡
      name: 'Balance',
      component: Balance
    },
    {
      path: '/initialize/bankData',             //账户名弹窗/明细账
      name: 'BankData',
      component: BankData
    },
    {
      path: '/initialize/objects',
      name: 'Objects',
      component: Objects
    },
    {
      path: '/initialize/objectTwo',
      name: 'ObjectTwo',
      component: ObjectTwo
    },
    {
      path: '/initialize/objectThree',
      name: 'ObjectThree',
      component: ObjectThree
    },
    {
      path: '/initialize/XsCompact',
      name: 'XsCompact',
      component: XsCompact
    },
    {
      path: '/initialize/CgCompact',
      name: 'CgCompact',
      component: CgCompact
    },
    {
      path: '/basicData/account',      //帐套管理
      name: 'Account',
      component: Account
    },
    {
      path: '/basicData/account/updateYear',      //帐套管理-会计区间修改
      name: 'updateYear',
      component: updateYear
    },
    {
      path: '/basicData/verifyProcess',    //审批流程
      name: 'verifyProcess',
      component: verifyProcess
    },
    {
      path: '/basicData/verifyProcess/oneAdd',    //审批流程-会计科目新增
      name: 'oneAdd',
      component: oneAdd
    },
    {
      path: '/basicData/verifyProcess/twoAdd',    //审批流程-部门新增
      name: 'twoAdd',
      component: twoAdd
    },
    {
      path: '/basicData/verifyProcess/threeAdd',    //审批流程-职员新增
      name: 'threeAdd',
      component: threeAdd
    },
    {
      path: '/basicData/verifyProcess/fourAdd',    //审批流程-金额新增
      name: 'fourAdd',
      component: fourAdd
    },
    {
      path: '/basicData/verifyProcess/fiveAdd',    //审批流程-审核人新增
      name: 'fiveAdd',
      component: fiveAdd
    },
    {
      path: '/basicData/BorrowCategory',        //借款类别模板
      name: 'BorrowCategory',
      component: BorrowCategory
    },
    {
      path: '/basicData/BorrowCategory/form',        //借款类别模板-新增
      name: 'BorrowCategoryForm',
      component: BorrowCategoryForm
    },
    {
      path: '/enableSystem',               //启用系统
      name: 'EnableSystem',
      component: EnableSystem
    },
//================== OA办公 ========================================
    {
      path: '/oa',
      name: 'OA',
      component: OA,
      redirect: '/basicData'
    },
//================== 统计报表 =======================================
    {
      path: '/report',
      name: 'Report',
      component: Report,
      redirect: '/basicData'
    },
//================== 调整管理 =======================================
    {
      path: '/manage',
      name: 'Manage',
      component: Manage,
      redirect: '/basicData'
    },
//================== 财务审批 =======================================
    {
      path: '/financial',
      name: 'Financial',
      component: Financial
    },
    {
      path: '/financial/borrowOrder',       //借款单
      name: 'BorrowOrder',
      component: BorrowOrder 
    },
    {
      path: '/financial/borrowOrder/form',      //借款单-新增
      name: 'BorrowOrderForm',
      component: BorrowOrderForm 
    },
    {
      path: '/financial/borrowOrder/selectBorrowCategory',      //借款单-选择借款类别
      name: 'selectBorrowCategory',
      component: selectBorrowCategory 
    },
    {
      path: '/financial/borrowOrder/approve',            //借款单-审核页面
      name: 'BorrowOrderApprovePage',
      component: BorrowOrderApprovePage
    },
    {
      path: '/financial/borrowOrder/view',               //借款单-查看
      name: 'viewBorrowOrder',
      component: viewBorrowOrder
    },
    {
      path: '/financial/borrowOrder/bank',            //借款单-银行选择窗口
      name: 'selectBorrowOrderBank',
      component: selectBorrowOrderBank
    },
    {
      path: '/financial/borrowApproveOrder',               //借款类别审批单
      name: 'BorrowApproveOrder',
      component: BorrowApproveOrder
    },
    {
      path: '/financial/borrowApproveOrder/form',               //借款类别审批单-新增
      name: 'BorrowApproveOrderForm',
      component: BorrowApproveOrderForm
    },
    {
      path: '/financial/borrowApproveOrder/approve',               //借款类别审批单-审核页面
      name: 'BorrowApproveOrderApprovePage',
      component: BorrowApproveOrderApprovePage
    },
    {
      path: '/financial/borrowApproveOrder/view',               //借款类别审批单-查看
      name: 'viewBorrowApproveOrder',
      component: viewBorrowApproveOrder
    },
//================== 个人中心 =======================================
    {
      path: '/center',
      name: 'Center',
      component: Center,
      redirect: '/basicData'
    },
//================== 登录注册 =======================================
    {
      path: '/login',
      name: 'Login',
      component: Login
    }
  ]
});

router.beforeEach((to, from, next) => {
  let isLogin = sessionStorage.getItem('isLogin') ? JSON.parse(sessionStorage.getItem('isLogin')) : '';
  if(isLogin['username']) {
    next();
  } else {
    if(to.path == '/login') {
      next();
    } else {
      next('/login');
    }
  }
});

export default router;